import React, { Component } from 'react'


// props 类型检查
import PropTypes from 'prop-types'

export class MainBanner extends Component {

  static defaultProps = {
    banner: [],
    title: '默认标题'
  }

  constructor(props) {
    super(props)
    this.state = {
      banner: props.banner,
      title: props.title
    }
  }
  render () {
    const { banner, title } = this.state
    console.log(banner, title);
    return (
      <div>
        轮播图: {title}
        <ul>
          {
            banner.map((item, index) => {
              return <li key={item.title}>{item.title}</li>
            })
          }
        </ul>
      </div>
    )
  }
}
// 默认值
// MainBanner.defaultProps = {
//   banner: [],
//   title: '默认标题'
// }
// props  类型检查
MainBanner.propsTypes = {
  banner: PropTypes.array,
  title: PropTypes.string
}


export default MainBanner